from typing import List

class Solution:
    def removeComments(self, source: List[str]) -> List[str]:
        block = False
        final_result = []
        res = ''
        for line in source:
            # print(line)
            i = 0
            while i < len(line):
                # print(line[:i], line[i:])
                if not block and line[i:i+2] == '//':
                    i += 2
                    break
                if not block and line[i:i+2] == '/*':
                    i += 2
                    block = True
                    continue
                if block and line[i:i+2] == '*/':
                    i += 2
                    block = False
                    continue
                if not block and i < len(line) and line[i:i+2] not in ['//', '/*']:
                    res += line[i]
                i += 1
            if not block:
                if len(res) != 0:
                    final_result.append(res)
                res = ''
        return final_result



if __name__ == "__main__":
    s = Solution()
    src = ["/*Test program */", "int main()", "{ ", "  // variable declaration ", "int a, b, c;", "/* This is a test", "   multiline  ", "   comment for ", "   testing */", "a = b + c;", "}"]
    print(s.removeComments(src))
    src = ["a/*comment", "line", "more_comment*/b"]
    print(s.removeComments(src))
    src = ["e/*/eabeea/*///*c*////*dc*//bcadcde/*/acbe//*d/*/*//ae//*dc//*cc//*//*eaebb*//"]
    print(s.removeComments(src))
